/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.fiu.accesslog.statistics;

import java.util.Comparator;


/**
 *
 * @author Hasan Mahmud
 * @date Jun 10, 2012
 */
public class InfoComparatorByTotalHit implements Comparator<Info>
{
      private boolean isAscending = false;
      public InfoComparatorByTotalHit(boolean isAscending)
      {
            this.isAscending = isAscending;
      }
     @Override
      public int compare(Info o1, Info o2)
      {
            int result = 0;
            if(o1.totalHit > o2.totalHit  )
            {
                  result = -1;
            }
            else if (o1.totalHit < o2.totalHit  )
            {
                  result = 1;
            }
            
            if(isAscending)
            {
                  result *= -1;
            }
           return result;
      }

}
